package cn.ybk.basic.controller;

import cn.ybk.basic.service.VerifyCodeService;
import cn.ybk.basic.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@RequestMapping("/verifyCode")
public class VerifyCodeController {

    @Autowired
    private VerifyCodeService verifyCodeService;

    // 手机图片验证码
    @GetMapping("/image/{imageCodeKey}")
    public AjaxResult verifyCode(@PathVariable("imageCodeKey") String imageCodeKey) throws IOException {
        String verifyCode = verifyCodeService.verifyCode(imageCodeKey);
        return AjaxResult.me().success(verifyCode);
    }

    // 邮箱图片验证码
    @GetMapping("/emailImage/{emailImageCodeKey}")
    public AjaxResult verifyEmailCode(@PathVariable("emailImageCodeKey") String emailImageCodeKey) throws IOException {
        String verifyEmailCode = verifyCodeService.verifyEmailCode(emailImageCodeKey);
        return AjaxResult.me().success(verifyEmailCode);
    }


}
